package com.zbkj.crmeb.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.crmeb.store.dao.ShopDao;
import com.zbkj.crmeb.store.model.Shop;
import com.zbkj.crmeb.store.request.ShopRequest;
import com.zbkj.crmeb.store.service.ShopService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShopServiceImpl extends ServiceImpl<ShopDao, Shop> implements ShopService {

    @Resource
    private ShopDao shopDao;

    @Override
    public List<Shop> findAll(ShopRequest request) {
        LambdaQueryWrapper<Shop> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(request.getName())) {
            lambdaQueryWrapper.like(Shop::getName, request.getName());
        }
        if (request.getStatus()!=null) {
            lambdaQueryWrapper.eq(Shop::getStatus, request.getStatus());
        }
        if (request.getIsDel()!=null) {
            lambdaQueryWrapper.eq(Shop::getIsDel, request.getIsDel());
        }
        lambdaQueryWrapper.orderByDesc(Shop::getId);
        return shopDao.selectList(lambdaQueryWrapper);
    }

}
